<template>
	<view>
		
		<block v-if="loading">
			<empty :loading="true"></empty>
		</block>
		<block v-else>
			
			<staffAuth>
				<arrowNav :url="`/pages/maintainRecords/maintainRecordsSave?id=${params.id}`">
					<view class="plr15 ptb10 flex left">
						<text class="pr5 fz16 sIcon-addCircle bold main"></text>
						<view>
							添加记录
						</view>
					</view>
				</arrowNav>
			</staffAuth>
			
			
			<view class="mt10">
				<view class=" whiteBg  mb10 " v-for="( item , index) in page.list" :key="index">
					
					<view class="pd pb10">
						
						<view class="flex ">
							<view>
								<text class="grey mr5">类型</text>
							</view>
							<view class="main">
								{{item.typeStr}}
							</view>
						</view>
						<view class="flex pt5">
							<view>
								<text class="grey mr5">记录时间</text>
							</view>
							<view>
								{{item.createTime}}
							</view>
						</view>
						<view class="flex pt5">
							<view>
								<text class="grey mr5">因子</text>
							</view>
							<view>
								{{item.recordsName}}
							</view>
						</view>
						<view class="flex pt5">
							<view>
								<text class="grey mr5">有效期至</text>
							</view>
							<view>
								{{item.deadline}}
							</view>
						</view>
						<view class="flex pt5">
							<view>
								<text class="grey mr5">结果</text>
							</view>
							<view>
								{{item.result}}
							</view>
						</view>
					</view>
					
					<view class="pd ptb10  bt dashed">
						
						<view class="flex">
							<view>
								<text class="grey mr5">运维公司</text>
							</view>
							<view>
								{{item.name}}
							</view>
						</view>
						
						<view class="flex pt5">
							<view>
								<text class="grey mr5">记录人</text>
							</view>
							<view>
								{{item.recorder}}
							</view>
						</view>
					</view>
					
				</view>
			</view>

			<empty :loading="false" :list="page.list"></empty>

		</block>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				params : {id:""}, 
				page : {
					list : [] ,
					lastPage : false ,
					pageNumber : 1 ,
					pageSize : 10
				},
				loading : true ,
				refresh : false 
			}
		},
		
		onLoad(p) {
			this.params = p ;
		},
		
		onShow() {
			this.page.pageNumber = 1 ;
			this.loadData();
		},
		
		onReachBottom() {
			if (this.page.lastPage) {
				return ;
			}
			this.page.pageNumber ++ ;
			this.loadData();
		},
		
		onPullDownRefresh() {
			if (this.refresh) {
				return ;
			}
			uni.startPullDownRefresh({});
			this.refresh = true ;
			this.page.pageNumber = 1 ;
			this.loadData();
		},
		
		methods: {
			
			loadData:function(e){
				var data = {
					pageNumber : this.page.pageNumber ,
					pageSize : this.page.pageSize ,
					"stationId" : this.params.id 
				} ;
				this.kit.get("/api/maintainRecords/list",data,res => {
					if (res.page.pageNumber > 1) {
						res.page.list = this.page.list.concat(res.page.list);
					}
					this.page = res.page ;
					this.loading = false ;
					this.refresh = false ;
				});
			},
			
		}
	}
</script>